package cn.the.angry.anim;

import java.awt.image.BufferedImage;

import cn.the.angry.sprite.Sprite;

public class Animation extends Sprite {
	
	int tmpCount;
	
	public Animation(BufferedImage[] frames){
		super(frames);
		tmpCount = frames.length;
	}
	
	@Override
	public void update(){
		if(active){
			long curNanoTime = System.nanoTime();
			if(lastUpdateTime==0){
				lastUpdateTime = curNanoTime;
			}
			if (curNanoTime-lastUpdateTime > updateTime*1000000) {
				if (tmpCount > 0) {
					getNextFrame();
					lastUpdateTime = System.nanoTime();
				}
				tmpCount--;
			}
		}
	}
	
	
}

	